package cn.hallele.leinsteining.ms.auditcenter.domain.log;

import cn.hallele.leinsteining.mc.infrastructure.metadata.io.Page;
import cn.hallele.leinsteining.ms.auditcenter.domain.log.das.LogDomainDas;
import cn.hallele.leinsteining.ms.auditcenter.domain.log.domain.LogDomain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * LogDomainService
 *
 * @author anle5
 * @since 2024/8/11 20:12
 */
@Slf4j
@Service
public class LogDomainService {
    @Autowired
    private LogDomainDas logDomainDas;

    /**
     * 查询日志信息
     *
     * @param condition 查询条件
     * @param pageNo    页码
     * @param pageSize  每页最大数量
     * @return 结果集
     */
    public Page<LogDomain> queryAll(LogDomain condition, int pageNo, int pageSize) {
        pageNo = Math.max(pageNo, 1);
        pageSize = Math.max(pageSize, 1);
        return logDomainDas.findAllByPage(condition, pageNo, pageSize);
    }

    /**
     * 添加单个日志记录
     *
     * @param logDomain logDomain
     * @return 单个日志记录
     */
    public LogDomain saveOne(LogDomain logDomain) {
        return logDomainDas.saveOne(logDomain);
    }
}
